//
//  SettingControl.m
//  FreeTime
//
//  Created by ti on 16/8/30.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "SettingControl.h"
#import "Header.h"
#import "SettingCell.h"
#import "InformControl.h"
#import "CleanCacheControl.h"


@interface SettingControl (){
    NSArray *arr;
    UIButton *quitLoginBt;
}

@end

@implementation SettingControl
- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    [self setupUI];
}

- (void)setupUI {
    self.navigationItem.title = @"设置";
    self.tableView.frame = CGRectMake(0, 15, WindowWidth, WindowHeight);
    self.tableView.showsVerticalScrollIndicator = NO;
    //    self.tableView.scrollEnabled = NO;
    [self.tableView registerClass:[SettingCell class] forCellReuseIdentifier:@"Cell"];
    arr = @[@"消息通知",@"清理缓存",@"给喵会好评"];
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, WindowHeight-147-15)];
    [self.view addSubview:footView];
    quitLoginBt = [UIButton buttonWithType:UIButtonTypeCustom];
    quitLoginBt.frame = CGRectMake(90, 45, WindowWidth-180, 50);
    [quitLoginBt setBackgroundImage:[UIImage imageNamed:@"querenbiao"] forState:UIControlStateNormal];
    UILabel * quitLoginLbl = [ReduceCode creatLabelWithFrame:CGRectMake((WindowWidth-180)/2-90, 1.5, 180, 40) title:@"退出登录" titleColor:[UIColor whiteColor] font:14 textAlignment:1];
    [quitLoginBt addSubview:quitLoginLbl];
    [quitLoginBt addTarget:self action:@selector(QuitLoginClick) forControlEvents:UIControlEventTouchUpInside];
    [footView addSubview:quitLoginBt];

    UILabel *versionL = [ReduceCode creatLabelWithFrame:CGRectMake(WindowWidth/2-50, CGRectGetMaxY(quitLoginBt.frame)+10, 100, 12) title:@"喵会1.0" titleColor:[ImageUtil colorWithRgb:0x999999] font:12 textAlignment:NSTextAlignmentCenter];
    [footView addSubview:versionL];

    self.tableView.tableFooterView = footView;
}
- (void)QuitLoginClick {
    
}
#pragma mark -UITableView--
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SettingCell *cell = [[SettingCell alloc] init];
    cell.titleL.text = [arr objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *VC = @[[[InformControl alloc] init],
                    [[CleanCacheControl alloc] init],
                    [[CleanCacheControl alloc] init] ];
    
    [self.navigationController pushViewController:[VC objectAtIndex:indexPath.row] animated:YES];
}

@end
